<div class="layui-form-item">
	<div class="layui-inline">
		<label class="layui-form-label">拼音：</label>
		<div class="layui-input-inline">
			<input name="pinyin" id="pinyin" value="{$pinyin}" lay-verify="required" autocomplete="off" placeholder="请输入全拼" class="layui-input" type="text">
		</div>
	</div>
	<div class="layui-inline">
		<label class="layui-form-label">简拼：</label>
		<div class="layui-input-inline">
			<input name="code" id="code" value="{$code}" lay-verify="required" autocomplete="off" placeholder="请输入简拼" class="layui-input" type="text">
		</div>
	</div>
</div>

<script>
layui.use(['form','layer'], function() {
	var layer = layui.layer,
	form = layui.form,
    $ = layui.$;
	
	$(".pinyin").change(function(){
		var name = $.trim($(this).val());
		if(!name){
			layer.msg("关键词不能为空");
			return false;	
		}
		$.get("/?app=widget&act=pinyin" , { "action":"getPinyin" , "keywords":name } , function(data){
			$("#pinyin").val(data.pinyin);
			$("#code").val(data.code);
		} , 'json');
		
		return false;
	});
});
</script>